package com.lzq.course.file.config;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 配置静态资源映射
 * 暴露给前端 才可以访问图片
 */
@Configuration
public class SpringMvcConfig implements WebMvcConfigurer {

    private final static Logger LOG = LoggerFactory.getLogger(SpringMvcConfig.class);

    /**
     * http:127.0.0.1:9003/file/f/teacher/xxx-头像.jpg
     * @param registry
     */
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        LOG.info("开启静态资源映射");
        registry.addResourceHandler("/f/**").addResourceLocations("file:E:/server_upload_file/course/");
    }
}
